<<<<<<< HEAD:cxx/algorithm/src/removeElement.cc
#include <vector>
#include "removeElement.h"
using namespace std;
int removeElement(vector<int>& nums, int val) {
    if(nums.size()<=0)
        return 0;
    else{
        int index = 0;
        int num_size = nums.size();
        while(index<num_size){
            if(nums.at(index) == val){
                if(nums.at(num_size-1) == val){
                    nums.pop_back();
                    num_size -= 1;
                }else{
                    swap(nums.at(index),nums.at(num_size-1));
                    nums.pop_back();
                    num_size -= 1;
                    index += 1;
                }
            }else{
                index += 1;
            }
        }
        return nums.size();

    }
}

=======
#include "removeElement.h"

#include <vector>
using namespace std;
int removeElement(vector<int>& nums, int val) {
  if (nums.size() <= 0)
    return 0;
  else {
    int index = 0;
    int num_size = nums.size();
    while (index < num_size) {
      if (nums.at(index) == val) {
        if (nums.at(num_size - 1) == val) {
          nums.pop_back();
          num_size -= 1;
        } else {
          swap(nums.at(index), nums.at(num_size - 1));
          nums.pop_back();
          num_size -= 1;
          index += 1;
        }
      } else {
        index += 1;
      }
    }
    return nums.size();
  }
}
>>>>>>> dev:cxx/algorithm/common/src/removeElement.cc
